import {merge} from 'lodash';

const toString = Object.prototype.toString;
type voidValue = null | undefined;

export function isDate (val: any): val is Date {
  return toString.call(val) === '[object Date]';
}

export function isPlainObject (val: any): val is Object {
  return toString.call(val) === "[object Object]";
}

export function isVoidValue (val: any): val is voidValue {
  return val === null || val === undefined;
}

export function extend<T, U>(to: T, from: U): T & U {
  for (const key in from) {
    (to as T & U)[key] = from[key] as any
  }
  return to as T & U
}

export const deepMerge = merge;